<!--
Copyright (C) 2007 James Ward
http://www.jamesward.org

Updated, Alex Russell, 2008
http://alex.dojotoolkit.org

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-->
<html>
	<head>
		<link rel="stylesheet" href="resources/main.css" type="text/css">
		<script type="text/javascript" src="dojo/dojo/dojo.js"></script>
		<script type="text/javascript" src="dojo/dojo/cookie.js"></script>
		<script type="text/javascript" src="resources/timing.js"></script>
		<script type="text/javascript">
			dojo.require("dojo.cookie");
			dojo.addOnLoad(function(){
				var url = new dojo._Url(window.location);
				var rows = 5000;
				if(url.query){
					rows = dojo.queryToObject(url.query).rows||rows;
				}
				timing.tic("transferTime");
				dojo.xhrGet({
					handleAs: "text",
					url: "data.jsp",
					content: {
						output: "json",
						count: rows,
						start: 0
					},
					load: function(data, ioArgs){
						var tt = timing.toc("transferTime");

						var st = parseInt(dojo.cookie("serverExecTime"));

						timing.setTime("serverExecTime", st);
						timing.setTime("transferTime", tt-st);

						timing.size("bandwidth", data);

						timing.tic("parseTime");
						var jsonData = dojo.fromJson(data);
						timing.toc("parseTime");

						timing.tic("renderTime");
						var html = [
							'<table id="dataTable"><tbody>'
						];
						dojo.forEach(jsonData, function(i){
							html.push('<tr>');
							html.push('<td>', i.id, '</td>');
							html.push('<td>', i.age, '</td>');
							html.push('<td>', i["class"], '</td>');
							html.push('<td>', i.education, '</td>');
							html.push('<td>', i.maritalStatus, '</td>');
							html.push('<td>', i.race, '</td>');
							html.push('<td>', i.sex, '</td>');
							html.push('</tr>');
						});
						html.push("</tbody></table>");
						dojo.byId("grid").innerHTML = html.join("");
						timing.toc("renderTime");

						timing.report();
					}
				});
			});
		</script>
	</head>
	<body>
		<div id="grid">
		</div>
	</body>
</html>
